package yu.liu.personal.app.myapplication.components.items;

import android.content.Context;
import android.graphics.Color;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import yu.liu.personal.app.myapplication.R;
import yu.liu.personal.app.myapplication.components.ViewCollection;
import yu.liu.personal.app.myapplication.models.AVGCompareItem;

/**
 * Created by yu.liu on 2016/9/30.
 */

public class ComparePanelItem extends ViewCollection {

    @BindView(R.id.tvNameCompPop)
    TextView tvNameCompPop;

    @BindView(R.id.tvTypeStarCompPop)
    TextView tvTypeStarCompPop;

    @BindView(R.id.tvHPCompPop)
    TextView tvHPCompPop;

    @BindView(R.id.tvArmorCompPop)
    TextView tvArmorCompPop;

    @BindView(R.id.tvShieldCompPop)
    TextView tvShieldCompPop;

    @BindView(R.id.tvResistCompPop)
    TextView tvResistCompPop;

    @BindView(R.id.tvAtkCompPop)
    TextView tvAtkCompPop;

    @BindView(R.id.tvScoutCompPop)
    TextView tvScoutCompPop;

    @BindView(R.id.tvSpdCompPop)
    TextView tvSpdCompPop;

    @BindView(R.id.tvOilCompPop)
    TextView tvOilCompPop;

    @BindView(R.id.tvAmmoCompPop)
    TextView tvAmmoCompPop;

    private AVGCompareItem item;

    public ComparePanelItem(Context context) {
        super(context);
    }

    public void setItem(AVGCompareItem item) {
        this.item = item;
    }

    @Override
    protected void loadViews() {
        ButterKnife.bind(this, contentView);
    }

    @Override
    public void updateViews() {
        if(item != null) {
            tvNameCompPop.setText(item.name);
            tvTypeStarCompPop.setText(""+item.stars+"星"+item.type);
            if(item.flagHP == null) {
                tvHPCompPop.setText("血:"+String.valueOf(item.hp)+"-E");
                tvHPCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagHP) {
                    tvHPCompPop.setText("血:"+String.valueOf(item.hp)+"-H");
                    tvHPCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvHPCompPop.setText("血:"+String.valueOf(item.hp)+"-L");
                    tvHPCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagAmor == null) {
                tvArmorCompPop.setText("甲:"+String.valueOf(item.armor)+"-E");
                tvArmorCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagAmor) {
                    tvArmorCompPop.setText("甲:"+String.valueOf(item.armor)+"-H");
                    tvArmorCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvArmorCompPop.setText("甲:"+String.valueOf(item.armor)+"-L");
                    tvArmorCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagShield == null) {
                tvShieldCompPop.setText("盾:"+String.valueOf(item.shield)+"-E");
                tvShieldCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagShield) {
                    tvShieldCompPop.setText("盾:"+String.valueOf(item.shield)+"-H");
                    tvShieldCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvShieldCompPop.setText("盾:"+String.valueOf(item.shield)+"-L");
                    tvShieldCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagResist == null) {
                tvResistCompPop.setText("抗:"+String.valueOf(item.resist)+"-E");
                tvResistCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagResist) {
                    tvResistCompPop.setText("抗:"+String.valueOf(item.resist)+"-H");
                    tvResistCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvResistCompPop.setText("抗:"+String.valueOf(item.resist)+"-L");
                    tvResistCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagAtk == null) {
                tvAtkCompPop.setText("攻:"+String.valueOf(item.atk)+"-E");
                tvAtkCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagAtk) {
                    tvAtkCompPop.setText("攻:"+String.valueOf(item.atk)+"-H");
                    tvAtkCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvAtkCompPop.setText("攻:"+String.valueOf(item.atk)+"-L");
                    tvAtkCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagScout == null) {
                tvScoutCompPop.setText("侦:"+String.valueOf(item.scout)+"-E");
                tvScoutCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagScout) {
                    tvScoutCompPop.setText("侦:"+String.valueOf(item.scout)+"-H");
                    tvScoutCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvScoutCompPop.setText("侦:"+String.valueOf(item.scout)+"-L");
                    tvScoutCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagSpd == null) {
                tvSpdCompPop.setText("速:"+String.valueOf(item.spd)+"-E");
                tvSpdCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagSpd) {
                    tvSpdCompPop.setText("速:"+String.valueOf(item.spd)+"-H");
                    tvSpdCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvSpdCompPop.setText("速:"+String.valueOf(item.spd)+"-L");
                    tvSpdCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagOil == null) {
                tvOilCompPop.setText("油:"+String.valueOf(item.oilConsume)+"-E");
                tvOilCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagOil) {
                    tvOilCompPop.setText("油:"+String.valueOf(item.oilConsume)+"-H");
                    tvOilCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvOilCompPop.setText("油:"+String.valueOf(item.oilConsume)+"-L");
                    tvOilCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }

            if(item.flagAmmo == null) {
                tvAmmoCompPop.setText("弹:"+String.valueOf(item.ammoConsume)+"-E");
                tvAmmoCompPop.setTextColor(Color.parseColor("#111111"));
            } else {
                if(item.flagAmmo) {
                    tvAmmoCompPop.setText("弹:"+String.valueOf(item.ammoConsume)+"-H");
                    tvAmmoCompPop.setTextColor(Color.parseColor("#FF3030"));
                } else {
                    tvAmmoCompPop.setText("弹:"+String.valueOf(item.ammoConsume)+"-L");
                    tvAmmoCompPop.setTextColor(Color.parseColor("#458B00"));
                }
            }
        }
    }
}
